package com.sunyard.layoutit.server;

import org.restlet.Component;
import org.restlet.data.Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sunyard.layoutit.application.SimpleDefaultApplication;
import com.sunyard.layoutit.application.StaticResourceApplication;
import com.sunyard.layoutit.common.ApplicationConfig;

public class StartServer {

	private static final Logger logger = LoggerFactory.getLogger(StartServer.class);

	public static void main(String[] args) throws Exception {
		ApplicationConfig.init() ;
//		System.setProperty("org.restlet.engine.loggerFacadeClass", "org.restlet.ext.slf4j.Slf4jLoggerFacade");
		Component component = new Component();
		component.getClients().add(Protocol.FILE);
		component.getServers().add(Protocol.HTTP, 8080);
		component.getDefaultHost().attach("/resources",new StaticResourceApplication());
		component.getDefaultHost().attach(ApplicationConfig.URI_PATTERN,new SimpleDefaultApplication());
		component.start();
		logger.info("RESTLET 服务已经启动 ...");
	}
}
